package main

import "fmt"

type Pet2 interface {
	SetName(name string)
	Name() string
	Category() string
}
type Dog2 struct {
	name string
}

// 指针方法
func (dog *Dog2) SetName(name string) {
	dog.name = name
}

// 值方法
func (dog Dog2) Name() string {
	return dog.name
}

// 值方法
func (dog Dog2) Category() string {
	return "dog"
}
func main() {
	dog := Dog2{"litite dog"}
	_, ok := interface{}(dog).(Pet2)
	fmt.Printf("Dog implements interface Pet: %v\n", ok)
	_, ok = interface{}(&dog).(Pet2)
	fmt.Printf("*Dog implements interface Pet: %v\n", ok)

	var pet Pet2 = &dog
	fmt.Printf("This pet is a %s, the name is %q.\n",
		pet.Category(), pet.Name())
}
